/*
 * @Author: LVGRAPE
 * @LastEditors: LVGRAPE
 */
#ifndef __COMBOS_H_
#define __COMBOS_H_

#include "at32f421.h"
#include "rtthread.h"

    typedef enum combosList
    {
        COMBOS_1 = 0,
        COMBOS_2,
        COMBOS_3,
        COMBOS_4,
        COMBOS_5,
        COMBOS_6,
        COMBOS_7,
        COMBOS_8,
        COMBOS_9,
        COMBOS_10,
        COMBOS_11,
        COMBOS_12,
        COMBOS_13,
        COMBOS_14,
        COMBOS_15,
        COMBOS_16,
        COMBOS_COUNT,
    } combosList_e;
    typedef enum combosState
    {
        COMBOS_PAUSE = 0,
        COMBOS_RUN,
        COMBOS_RESTART,
        COMBOS_STOP,
    } combosState_e;

    typedef struct vehicleCtrlCmdNew
    {
        int16_t throttle;      //前进+/后退-
        int16_t turn;          //左转-/右转+
        int16_t shitf;         //左移-/左移+
        int16_t turretPitch;  //炮台角度
        uint16_t fire;         //火力强度
        uint16_t moveTime;    //行驶时间(ms)
        uint16_t fireTime;    //开火时间(ms)

    } __attribute__((packed)) vehicleCtrlCmdNew_s;
    typedef struct combosInfo
    {
        vehicleCtrlCmdNew_s *cmd;
        uint8_t cmdUsed;
        uint8_t CurrentCmd;
        uint8_t state;
        uint8_t statePre;
        uint8_t executeTimes; //指令执行次数
        uint8_t executedTimes; //已指令执行次数
        uint16_t movedTime;    //已行驶时间(ms)
        uint16_t firedTime;    //已开火时间(ms)
        uint32_t timestamp;
    } __attribute__((packed)) combos_s;
void program_vehicleWheelCtrl(int16_t throttle, //前进+/后退-
                              int16_t shitf,    //左移-/左移+
                              int16_t turn      //左转-/右转+

);
void program_gunturretCtrl(uint8_t gunPitch, uint8_t fire);
void vehicelCmdInit(combos_s* combos, const vehicleCtrlCmdNew_s* cmd, uint8_t cmdCount, uint8_t cycleTimes);
void vehicleCmdReset(combos_s* combos);
void vehicelCmdRun(combos_s* combos);
void vehicelCmdSetState(combos_s* combos, combosState_e newState);
combosState_e vehicelCmdGetState(combos_s* combos);


void set_combos_0_cmd(uint8_t index,
                      uint8_t maxIndex,
                      int16_t throttle,
                      int16_t turn,
                      int16_t shitf,
                      uint16_t turretPitch,
                      uint16_t fire,
                      uint16_t moveTime,
                      uint16_t fireTime);
void camera_program_init(void);
void camera_program_loop(void);
#endif
